home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
cpphtp2
/
code.jar
/
code
/
ch11
/
fig11_26.txt
< prev
next >
Wrap
Text File
|
1998-02-27
|
780b
|
23 lines
1 // Fig. 11.26: fig11_26.cpp
2 // Displaying floating-point values in system default,
3 // scientific, and fixed formats.
4 #include <iostream.h>
5
6 int main()
7 {
8 double x = .001234567, y = 1.946e9;
9
10 cout << "Displayed in default format:\n"
11 << x << '\ ' << y << '\n';
12 cout.setf( ios::scientific, ios::floatfield );
13 cout << "Displayed in scientific format:\n"
14 << x << '\ ' << y << '\n';
15 cout.unsetf( ios::scientific );
16 cout << "Displayed in default format after unsetf:\n"
17 << x << '\ ' << y << '\n';
18 cout.setf( ios::fixed, ios::floatfield );
19 cout << "Displayed in fixed format:\n"
20 << x << '\ ' << y << endl;
21 return 0;
22 }